package com.cms.common;


import com.cms.common.interceptor.JwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new JwtInterceptor())
//                .addPathPatterns("/**") //拦截所有请求，来判断token是否合法，最后再决定是否登录
//                .excludePathPatterns("/user/login","/user/register","**/export","**/import");
        registry.addInterceptor(jwtInterceptor())
                .addPathPatterns("/**") //拦截所有请求，来判断token是否合法，最后再决定是否登录
                .excludePathPatterns("/user/login","/user/register","/user/export","/user/import","/file/*", "/goods/list", "/goodstype/list", "/source/list", "/goods/{id}");
    }

    @Bean
    public JwtInterceptor jwtInterceptor(){
        return new JwtInterceptor();
    }
}

